package com.example.netty.inoutbound;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class MyServerHandler extends SimpleChannelInboundHandler<Long> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Long msg) throws Exception {
//        System.out.println("从客户端" + ctx.channel().remoteAddress() +
//                "读取到 long" + msg);
                System.out.println("从客户端" + ctx.channel().remoteAddress() +
                "读取到 int" + msg);

        // 将读到的数据返回给客户端
        ctx.channel().writeAndFlush(93843L);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        cause.printStackTrace();
        ctx.close();
    }
}
